/*   1:    */ package indi.tshoiasc.simstr.config;

/*   2:    */
/*   3:    */ import indi.tshoiasc.simstr.SimStrengthMain;
/*   4:    */ import indi.tshoiasc.simstr.utils.GeneralOperate;
/*   5:    */ import indi.tshoiasc.simstr.utils.ItemOperate;
/*   6:    */ import java.io.File;
/*   7:    */ import java.util.ArrayList;
/*   8:    */ import java.util.HashMap;
/*   9:    */ import java.util.List;
/*  10:    */ import java.util.Map;
/*  11:    */ import org.bukkit.configuration.file.FileConfiguration;
/*  12:    */ import org.bukkit.configuration.file.YamlConfiguration;
/*  13:    */ import org.bukkit.inventory.ItemStack;

/*  14:    */
/*  15:    */ public class ConfigLoader
/* 16: */ {
	/* 17: */ public static FileConfiguration config;
	/* 18: 17 */ public static YamlConfiguration itemyml = new YamlConfiguration();
	/* 19: 18 */ public static YamlConfiguration costitemyml = new YamlConfiguration();
	/* 20: 19 */ public static Map<String, ItemStack> itemMap = new HashMap<String, ItemStack>();
	/* 21: 20 */ public static Map<Integer, ConfigHolder> list = new HashMap<Integer, ConfigHolder>();

	/* 22: */
	/* 23: */ public void loadConfig(SimStrengthMain plugin)
	/* 24: */ {
		/* 25: */ try
		/* 26: */ {
			/* 27: 24 */ File configFile = new File(plugin.getDataFolder(), "config.yml");
			/* 28: 25 */ if (!configFile.exists()) {
				/* 29: 26 */ plugin.saveDefaultConfig();
				/* 30: */ }
			/* 31: 28 */ config = plugin.getConfig();
			/* 32: */ }
		/* 33: */ catch (Exception e)
		/* 34: */ {
			/* 35: 30 */ e.printStackTrace();
			/* 36: */ }
		/* 37: 32 */ File itemFile = new File(plugin.getDataFolder(), "item.yml");
		/* 38: 33 */ if (!itemFile.exists()) {
			/* 39: 34 */ plugin.saveResource("item.yml", false);
			/* 40: */ }
		/* 41: 36 */ itemyml = YamlConfiguration.loadConfiguration(itemFile);
		/* 42: */
		/* 43: 38 */ File costitemFile = new File(plugin.getDataFolder(), "costitem.yml");
		/* 44: 39 */ if (!costitemFile.exists()) {
			/* 45: 40 */ plugin.saveResource("costitem.yml", false);
			/* 46: */ }
		/* 47: 42 */ costitemyml = YamlConfiguration.loadConfiguration(costitemFile);
		/* 48: 43 */ toConfigHolder();
		/* 49: */ }

	/* 50: */
	/* 51: */ public static void toConfigHolder()
	/* 52: */ {
		/* 53: 47 */ List<String> s = config.getStringList("Open");
		/* 54: 48 */ for (int i = 0; i < s.size(); i++)
		/* 55: */ {
			/* 56: 49 */ int ID = itemyml.getInt((String) s.get(i) + ".id");
			/* 57: 50 */ String name = itemyml.getString((String) s.get(i) + ".defaultname");
			/* 58: 51 */ int Mode = itemyml.getInt((String) s.get(i) + ".mode");
			/* 59: 52 */ int normal_CostMoney = itemyml.getInt((String) s.get(i) + ".normal.costMoney");
			/* 60: 53 */ List<Integer> normal_Random = itemyml.getIntegerList((String) s.get(i) + ".normal.random");
			/* 61: */
			/* 62: 55 */ List<String> normal_CostItem = itemyml.getStringList((String) s.get(i) + ".normal.costItem");
			/* 63: 56 */ List<ItemStack> itemstackArray_normal = new ArrayList<ItemStack>();
			/* 64: 58 */ for (String str : normal_CostItem)
			/* 65: */ {
				/* 66: 59 */ String[] itemArray = str.split(" ");
				/* 67: 60 */ if (itemMap.containsKey(itemArray[0]))
				/* 68: */ {
					/* 69: 61 */ ItemStack im = ((ItemStack) itemMap.get(itemArray[0])).clone();
					/* 70: 62 */ im.setAmount(Integer.valueOf(itemArray[1]).intValue());
					/* 71: 63 */ itemstackArray_normal.add(im);
					/* 72: */ }
				/* 73: */ else
				/* 74: */ {
					/* 75: 65 */ int tempID = costitemyml.getInt(itemArray[0] + ".id");
					/* 76: 66 */ String tempName = costitemyml.getString(itemArray[0] + ".name");
					/* 77: 67 */ List<String> tempLore = costitemyml.getStringList(itemArray[0] + ".lore");
					/* 78: 68 */ ItemStack temp = ItemOperate.generateItem(tempID, tempName, tempLore,
							Integer.valueOf(itemArray[1]));
					/* 79: 69 */ temp.setAmount(Integer.valueOf(itemArray[1]).intValue());
					/* 80: 70 */ itemstackArray_normal.add(temp);
					/* 81: 71 */ itemMap.put(itemArray[0], temp.clone());
					/* 82: */ }
				/* 83: */ }
			/* 84: 74 */ int luck_CostMoney = itemyml.getInt((String) s.get(i) + ".luck.costMoney");
			/* 85: 75 */ int luck_addRandom = itemyml.getInt((String) s.get(i) + ".luck.addRandom");
			/* 86: 76 */ List<String> luck_CostItem = itemyml.getStringList((String) s.get(i) + ".luck.costItem");
			/* 87: 77 */ List<ItemStack> itemstackArray_luck = new ArrayList<ItemStack>();
			/* 88: */ List<String> tempLore2;
			/* 89: 79 */ for (String str : luck_CostItem)
			/* 90: */ {
				/* 91: 80 */ String[] itemArray = str.split(" ");
				/* 92: 81 */ if (itemMap.containsKey(itemArray[0]))
				/* 93: */ {
					/* 94: 82 */ ItemStack im = ((ItemStack) itemMap.get(itemArray[0])).clone();
					/* 95: 83 */ im.setAmount(Integer.valueOf(itemArray[1]).intValue());
					/* 96: 84 */ itemstackArray_luck.add(im);
					/* 97: */ }
				/* 98: */ else
				/* 99: */ {
					/* 100: 86 */ int tempID = costitemyml.getInt(itemArray[0] + ".id");
					/* 101: 87 */ String tempName = costitemyml.getString(itemArray[0] + ".name");
					/* 102: 88 */ tempLore2 = costitemyml.getStringList(itemArray[0] + ".lore");
					/* 103: 89 */ ItemStack temp1 = ItemOperate.generateItem(tempID, tempName, tempLore2,
							/* 104: 90 */ Integer.valueOf(itemArray[1]));
					/* 105: 91 */ itemstackArray_luck.add(temp1);
					/* 106: 92 */ itemMap.put(itemArray[0], temp1);
					/* 107: */ }
				/* 108: */ }
			/* 109: 95 */ int safe_CostMoney = itemyml.getInt((String) s.get(i) + ".safe.costMoney");
			/* 110: 96 */ List<String> safe_CostItem = itemyml.getStringList((String) s.get(i) + ".safe.costItem");
			/* 111: 97 */ List<ItemStack> itemstackArray_safe = new ArrayList<ItemStack>();
			/* 112: 98 */ for (String str : (List<String>) safe_CostItem)
			/* 113: */ {
				/* 114: 99 */ String[] itemArray = str.split(" ");
				/* 115:100 */ if (itemMap.containsKey(itemArray[0]))
				/* 116: */ {
					/* 117:101 */ ItemStack im = ((ItemStack) itemMap.get(itemArray[0])).clone();
					/* 118:102 */ im.setAmount(Integer.valueOf(itemArray[1]).intValue());
					/* 119:103 */ itemstackArray_safe.add(im);
					/* 120: */ }
				/* 121: */ else
				/* 122: */ {
					/* 123:105 */ int tempID = costitemyml.getInt(itemArray[0] + ".id");
					/* 124:106 */ String tempName3 = costitemyml.getString(itemArray[0] + ".name");
					/* 125:107 */ List<String> tempLore3 = costitemyml.getStringList(itemArray[0] + ".lore");
					/* 126:108 */ ItemStack temp2 = ItemOperate.generateItem(tempID, tempName3, tempLore3,
							/* 127:109 */ Integer.valueOf(itemArray[1]));
					/* 128:110 */ itemstackArray_safe.add(temp2);
					/* 129:111 */ itemMap.put(itemArray[0], temp2);
					/* 130: */ }
				/* 131: */ }
			/* 132:114 */ ConfigHolder ch = new ConfigHolder(ID, name, Mode, normal_CostMoney, itemstackArray_normal,
					normal_Random, /* 133:115 */ luck_CostMoney, itemstackArray_luck, luck_addRandom, safe_CostMoney,
					itemstackArray_safe);
			/* 134:116 */ list.put(Integer.valueOf(ID), ch);
			/* 135: */ }
		/* 136:118 */ ConfigHolder.Broadcast_content = config.getString("Broadcast.content");
		/* 137:119 */ ConfigHolder.Broadcast_level = config.getInt("Broadcast.level");
		/* 138:120 */ ConfigHolder.Cooldown = config.getInt("Cooldown");
		/* 139:121 */ ConfigHolder.addValue = config.getDouble("Strength.addValue");
		/* 140:122 */ ConfigHolder.successEffect = GeneralOperate.getEffect(config.getInt("Strength.successEffect"));
		/* 141:123 */ ConfigHolder.failEffect = GeneralOperate.getEffect(config.getInt("Strength.failEffect"));
		/* 142: */ }
	/* 143: */ }

/*
 * Location: C:\Users\Administrator\Desktop\插件\ClassicStrength (1).jar
 * 
 * Qualified Name: indi.tshoiasc.simstr.config.ConfigLoader
 * 
 * JD-Core Version: 0.7.0.1
 * 
 */